trigger DeleteCallPlan on CallPlan__c (before delete) {
    Profile p  = [select id from profile where name=: 'System Administrator' or name =: '系统管理员'];
    List<CallPlan__c> delList = new List<CallPlan__c>();
    if(system.trigger.isdelete){
     for (CallPlan__c cp : Trigger.old)
     {
         if((cp.CallPlanDate__c == date.today())&&(cp.PlanType__c == '计划外')){
             delList.add(cp);
             continue;
         }
         
         if((cp.CallDate__c <= datetime.now())&&(p.id != UserInfo.getProfileId())&& cp.Delete_mark__c==false){
             cp.addError('该记录不能被删除!');
         }
     }
   }
}